<template>
  <div>

    <el-dialog title="设置提现失败" :visible.sync="dialogVisible" width="30%">
      <el-form :model="form" ref="form" label-width="120px" style="width: 85%;">

        <el-form-item 
          label="用户">
          <template>
            {{drawInfo.full_name}}【{{drawInfo.phone}}】
          </template>
        </el-form-item>
        <el-form-item 
          label="银行账号">
          <template>
            {{drawInfo.account_name}}&nbsp;&nbsp;{{drawInfo.account_no}} 
          </template>
        </el-form-item>
        <el-form-item 
          label="提现金额">
          <template>
            ¥ {{drawInfo.money}}
          </template>
        </el-form-item>

        <el-form-item 
          label="状态">
          <template>
            <el-radio v-model="form.isFail" label="1">提现失败</el-radio>
          </template>
        </el-form-item>

        <el-form-item 
          label="失败原因" 
          prop="remark"
          :rules="[
            {required: true, message: '请输入提现失败原因', trigger: 'blur' }
          ]">
          <el-input type="textarea" clearable v-model="form.remark" placeholder="比如，绑定银行卡有误"></el-input>
        </el-form-item>

      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="closeEdit(false)">取 消</el-button>
        
        <SubmitButton 
          type="primary"
          :ref-form="()=>{return this.$refs['form'];}"
          :post-option="{url: setFailUrl, data: subFormData(), callback: setFailCB }"
          >确 定</SubmitButton>

      </div>

    </el-dialog>

  </div>
  
</template>


<script>

  import DrawCashApi from '../../api/DrawCashApi'

  import SubmitButton from '../common/SubmitButton'


  export default {
  	components: {
  		SubmitButton
  	},
  	data(){
  	  return {
        drawInfo: {},

        form: {
          id: '',
          remark: '',
          isFail: '1',
        },

        setFailUrl: DrawCashApi.URL_SET_FAIL,

  	  }
  	},
    props: ['isShow', 'rowDataFun'],
  	computed: {
      dialogVisible: {
        get: function(){
          return this.isShow;
        },
        set: function(newValue){
          this.closeEdit(false);
        }
      }
  	},
    watch: {
      dialogVisible: function(newVal, oldVal){
        if (newVal) {
          this.drawInfo = this.rowDataFun();
          this.form.id = this.drawInfo.id;
        }
      }
    },
  	created(){
  	  
  	},
  	methods: {
      setFailCB(json){
        this.closeEdit(true);
      },
      subFormData(){
        return this.form;
      },
      closeEdit(isSuccess){
        this.$refs['form'].resetFields();
        this.$root.eventHub.$emit('closeEditDialog', isSuccess);
      },
  	}
  }
</script>

